/*
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2014
 *
 * fileName:  SearchFactoryBean.java
 * author:  lei
 * Company:  Cloudland Studio
 * Createdate:  2013-9-19 下午10:08:29
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2013-9-19          Lei            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.search.plugin.spring;

import java.util.Collection;

import org.cloudland.search.SearchFactory;
import org.cloudland.search.Searcher;
import org.cloudland.search.build.SearchBuilder;
import org.cloudland.search.config.Configuration;
import org.springframework.beans.factory.InitializingBean;

/**
 * <pre>
 * TODO 请充分描述该类提供的作用, 或与其他类会有关联的使用。
 * 使用 {@link java.lang.Object#toString()}, 或者 {@link java.lang.Character Character} 等标签
 * </pre>
 * 
 * @ClassName SearchFactoryBean
 * @author lei
 * @version %I%, %G%
 * @see
 * @since JDK1.6
 * 
 */
public class SearchFactoryBean implements SearchFactory, InitializingBean {

	private SearchFactory factory;

	private Configuration cfg;

	/**
	 * @return
	 */
	public Collection<String> getSearcherName() {
		return factory.getSearcherName();
	}

	public Searcher getSearcher(String name) {
		return factory.getSearcher(name);
	}

	/**
	 * @throws Exception
	 */
	public void afterPropertiesSet() throws Exception {

		SearchBuilder build = new SearchBuilder(cfg);
		factory = build.build();
	}

	public Configuration getConfiguration() {
		return this.cfg;
	}

	public String getConfig() {
		return "";
	}

	public void setConfig(String config) {
		this.cfg = new Configuration(config);
	}

}
